package com.heima.test4.domin;

public class BankAccount {
    private String accountNumber;
    private String accountHolder;
    private double balance;
    static private int totalAccounts;

    public BankAccount() {
        totalAccounts++;
    }

    public BankAccount(String accountNumber, String accountHolder, double balance) {
        this.accountNumber = accountNumber;
        this.accountHolder = accountHolder;
        this.balance = balance;
        totalAccounts++;
    }

    public String getAccountNumber() {
        return accountNumber;
    }

    public void setAccountNumber(String accountNumber) {
        this.accountNumber = accountNumber;
    }

    public String getAccountHolder() {
        return accountHolder;
    }

    public void setAccountHolder(String accountHolder) {
        this.accountHolder = accountHolder;
    }

    public double getBalance() {
        return balance;
    }

    public void setBalance(double balance) {
        this.balance = balance;
    }

    public void deposit(double kun) {
        if (kun < 0) {
            System.out.println("您存款的金额不对，是负数");
            return;
        } else if (kun == 0) {
            System.out.println("您存款的金额为0，无效存款");
            return;
        }
        this.balance += kun;
        System.out.println("存款" + kun + "元");
    }

    public void withdraw(double kun) {
        if (kun < 0) {
            System.out.println("您取款的金额不对，是负数");
            return;
        } else if (kun == 0) {
            System.out.println("您取款的金额为0，无效取款");
            return;
        }
        this.balance -= kun;
        System.out.println("取款" + kun + "元");
    }

    public void balance() {
        System.out.println("余额为：" + balance);
    }

    public static void getTotalAccounts() {
        System.out.println("账户数为：" + totalAccounts);
    }
}
